package com.itheima.controller;

import com.itheima.domain.AjaxMsg;
import com.itheima.domain.Department;
import com.itheima.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author is me
 * @data 2021/1/30
 */
@Controller
@RequestMapping("/dept")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    /**
     * 查询所有职业信息返回json数据给客户端
     * @return
     */
    @RequestMapping("/findAll")
    @ResponseBody
    public AjaxMsg findAll(){
        List<Department> dept = departmentService.findAll();
        return AjaxMsg.success().add("department", dept);
    }

}
